﻿<Window x:Class="paravili.Ui.AlgorithmViewer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:chart="clr-namespace:Visifire.Charts;assembly=WPFVisifire.Charts"
        xmlns:configValues="clr-namespace:paravili.Steps;assembly=paravili"  
        xmlns:local="clr-namespace:paravili.Ui"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="1400" Height="950"  Title="Movement by differation, clustering and combining the clusters">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="600"></ColumnDefinition>
            <ColumnDefinition Width="300"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="40"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="616"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <Border>
            <StackPanel Orientation="Horizontal">
                <Button Name="m_saveConfiguration" Click="m_saveConfiguration_Click" >Save Configuration</Button>
                <Button Name="m_loadConfiguration" Click="m_loadConfiguration_Click"  >Load Configuration</Button>
                <CheckBox Content="Manual Mode" Name="m_autoMode" Click="m_autoMode_Click" VerticalAlignment="Center"/>
                <Button IsEnabled="{Binding Path=IsChecked,ElementName=m_autoMode}" Content="Next Frame" Click="Button_Click"/>
            </StackPanel>
        </Border>
        <Border Grid.ColumnSpan="3"  BorderBrush="Silver" BorderThickness="2" ></Border>
        <Label Grid.Row="1">Steps of the algorithm</Label>
        <Label Grid.Column="1" Grid.Row="1">Statistic data</Label>
        <Label Grid.Column="2" Grid.Row="1">Result</Label>
        <Grid   VerticalAlignment="Top" HorizontalAlignment="Center" Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.5*"></RowDefinition>
                <RowDefinition Height="0.5*"></RowDefinition>
            </Grid.RowDefinitions>

            <ScrollViewer Grid.Row="0">
                <ItemsControl Grid.Column="0" Name="ProcessSteps" Width="600">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border CornerRadius="5" BorderBrush="Silver" BorderThickness="2" Margin="5">
                                <StackPanel Orientation="Vertical">
                                    <Expander Header="{Binding Name}" IsExpanded="False">
                                        <ItemsControl ItemsSource="{Binding ConfigurableValues}">
                                            <ItemsControl.ItemTemplateSelector>
                                                <local:GeneralTemplateSelector>
                                                    <local:GeneralTemplateSelector.Templates>
                                                        <local:TemplateEntry  >
                                                            <local:TemplateEntry.DataTemplate >
                                                                <DataTemplate  DataType="{x:Type configValues:ConfigurableNumericValueEntry}">
                                                                    <Expander Header="{Binding Name}" IsExpanded="True">
                                                                        <StackPanel Orientation="Horizontal">
                                                                            <Slider x:Name="slider" Width="500" Value="{Binding Value}" Maximum="{Binding RangeTo}" Minimum="{Binding RangeFrom}" SmallChange="1"></Slider>
                                                                            <Label Content="{Binding Path=Value,ElementName=slider }" Width="50"/>
                                                                        </StackPanel>
                                                                    </Expander>

                                                                </DataTemplate>
                                                            </local:TemplateEntry.DataTemplate>
                                                        </local:TemplateEntry  >
                                                        <local:TemplateEntry  >
                                                            <local:TemplateEntry.DataTemplate >
                                                                <DataTemplate  DataType="{x:Type configValues:ConfigurableNumericDoubleValueEntry}">
                                                                    <Expander Header="{Binding Name}" IsExpanded="True">
                                                                        <StackPanel Orientation="Horizontal">
                                                                            <Slider x:Name="slider" Width="500" SmallChange="{Binding StepSize}" LargeChange="{Binding StepSize}" Value="{Binding Value}" Maximum="{Binding RangeTo}" Minimum="{Binding RangeFrom}"></Slider>
                                                                            <Label Content="{Binding Path=Value,ElementName=slider }" Width="50"/>
                                                                        </StackPanel>
                                                                    </Expander>

                                                                </DataTemplate>
                                                            </local:TemplateEntry.DataTemplate>
                                                        </local:TemplateEntry  >
                                                        <local:TemplateEntry  >
                                                            <local:TemplateEntry.DataTemplate >
                                                                <DataTemplate  DataType="{x:Type configValues:ConfigurableStringValueEntry}" >
                                                                    <Expander Header="{Binding Name}" IsExpanded="True">
                                                                        <StackPanel Orientation="Vertical">
                                                                            <TextBox Text="{Binding Value}" Width="270"/>
                                                                        </StackPanel>
                                                                    </Expander>
                                                                </DataTemplate>
                                                            </local:TemplateEntry.DataTemplate>
                                                        </local:TemplateEntry>
                                                        <local:TemplateEntry  >
                                                            <local:TemplateEntry.DataTemplate >
                                                                <DataTemplate  DataType="{x:Type configValues:ConfigurableBooleanValueEntry}" >
                                                                    <Expander Header="{Binding Name}" IsExpanded="True">
                                                                        <StackPanel Orientation="Vertical">
                                                                            <CheckBox IsChecked="{Binding Value}" Width="270"/>
                                                                        </StackPanel>
                                                                    </Expander>
                                                                </DataTemplate>
                                                            </local:TemplateEntry.DataTemplate>
                                                        </local:TemplateEntry>
                                                        <local:TemplateEntry  >
                                                            <local:TemplateEntry.DataTemplate >
                                                                <DataTemplate  DataType="{x:Type configValues:ConfigurableLabValueEntry}">
                                                                    <Expander Header="{Binding Name}" IsExpanded="True">
                                                                        <StackPanel>
                                                                            <StackPanel Orientation="Horizontal">
                                                                                <Slider x:Name="slider1" Width="500" SmallChange="1" LargeChange="1" Value="{Binding X}" Maximum="255" Minimum="0"></Slider>
                                                                                <Label Content="{Binding Path=Value,ElementName=slider1 }" Width="50"/>
                                                                            </StackPanel>
                                                                            <StackPanel Orientation="Horizontal">
                                                                                <Slider x:Name="slider2" Width="500" SmallChange="1" LargeChange="1" Value="{Binding Y}" Maximum="255" Minimum="0"></Slider>
                                                                                <Label Content="{Binding Path=Value,ElementName=slider2 }" Width="50"/>
                                                                            </StackPanel>
                                                                            <StackPanel Orientation="Horizontal">
                                                                                <Slider x:Name="slider3" Width="500" SmallChange="1" LargeChange="1" Value="{Binding Z}" Maximum="255" Minimum="0"></Slider>
                                                                                <Label Content="{Binding Path=Value,ElementName=slider3 }" Width="50"/>
                                                                            </StackPanel>
                                                                        </StackPanel>
                                                                    </Expander>

                                                                </DataTemplate>
                                                            </local:TemplateEntry.DataTemplate>
                                                        </local:TemplateEntry  >
                                                    </local:GeneralTemplateSelector.Templates>
                                                </local:GeneralTemplateSelector>
                                            </ItemsControl.ItemTemplateSelector>

                                        </ItemsControl>
                                    </Expander>
                                </StackPanel>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl >
            </ScrollViewer>
            <ScrollViewer Grid.Row="1">
                <ListView Grid.Column="0" Name="CaptureSources"  HorizontalAlignment="Stretch" Width="600">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Border CornerRadius="5" BorderBrush="Silver" BorderThickness="2" Margin="5">
                                <Expander Header="{Binding Name}" IsExpanded="False">
                                    <ItemsControl>
                                        <ItemsControl.ItemsSource>
                                            <Binding Path=".">
                                                <Binding.Converter>
                                                    <local:ObecjtToConfigurableValuesConverter/>
                                                </Binding.Converter>
                                            </Binding>
                                        </ItemsControl.ItemsSource>
                                        <ItemsControl.ItemTemplateSelector>
                                            <local:GeneralTemplateSelector>
                                                <local:GeneralTemplateSelector.Templates>
                                                    <local:TemplateEntry  >
                                                        <local:TemplateEntry.DataTemplate >
                                                            <DataTemplate  DataType="{x:Type configValues:ConfigurableNumericDoubleValueEntry}">
                                                                <Expander Header="{Binding Name}" IsExpanded="True">
                                                                    <StackPanel Orientation="Horizontal">
                                                                        <Slider x:Name="slider" Width="500" SmallChange="{Binding StepSize}" LargeChange="{Binding StepSize}" Value="{Binding Value}" Maximum="{Binding RangeTo}" Minimum="{Binding RangeFrom}"></Slider>
                                                                        <Label Content="{Binding Path=Value,ElementName=slider }" Width="50"/>
                                                                    </StackPanel>
                                                                </Expander>

                                                            </DataTemplate>
                                                        </local:TemplateEntry.DataTemplate>
                                                    </local:TemplateEntry  >
                                                    <local:TemplateEntry  >
                                                        <local:TemplateEntry.DataTemplate >
                                                            <DataTemplate  DataType="{x:Type configValues:ConfigurableLabValueEntry}">
                                                                <Expander Header="{Binding Name}" IsExpanded="True">
                                                                    <StackPanel>
                                                                        <StackPanel Orientation="Horizontal">
                                                                            <Slider x:Name="slider1" Width="500" SmallChange="1" LargeChange="1" Value="{Binding X}" Maximum="255" Minimum="0"></Slider>
                                                                            <Label Content="{Binding Path=Value,ElementName=slider1 }" Width="50"/>
                                                                        </StackPanel>
                                                                        <StackPanel Orientation="Horizontal">
                                                                            <Slider x:Name="slider2" Width="500" SmallChange="1" LargeChange="1" Value="{Binding Y}" Maximum="255" Minimum="0"></Slider>
                                                                            <Label Content="{Binding Path=Value,ElementName=slider2 }" Width="50"/>
                                                                        </StackPanel>
                                                                        <StackPanel Orientation="Horizontal">
                                                                            <Slider x:Name="slider3" Width="500" SmallChange="1" LargeChange="1" Value="{Binding Z}" Maximum="255" Minimum="0"></Slider>
                                                                            <Label Content="{Binding Path=Value,ElementName=slider3 }" Width="50"/>
                                                                        </StackPanel>
                                                                    </StackPanel>
                                                                </Expander>

                                                            </DataTemplate>
                                                        </local:TemplateEntry.DataTemplate>
                                                    </local:TemplateEntry  >
                                                    <local:TemplateEntry >
                                                        <local:TemplateEntry.DataTemplate >
                                                            <DataTemplate  DataType="{x:Type configValues:ConfigurableNumericValueEntry}">

                                                                <StackPanel Orientation="Vertical">
                                                                    <Label Content="{Binding Name}"></Label>
                                                                    <StackPanel Orientation="Horizontal">
                                                                        <Slider x:Name="slider" Width="500" Value="{Binding Value}" Maximum="{Binding RangeTo}" Minimum="{Binding RangeFrom}" SmallChange="1"></Slider>
                                                                        <Label Content="{Binding Path=Value,ElementName=slider }" Width="50"/>
                                                                    </StackPanel>
                                                                </StackPanel>

                                                            </DataTemplate>
                                                        </local:TemplateEntry.DataTemplate>
                                                    </local:TemplateEntry  >
                                                    <local:TemplateEntry  >
                                                        <local:TemplateEntry.DataTemplate >
                                                            <DataTemplate  DataType="{x:Type configValues:ConfigurableStringValueEntry}" >
                                                                <StackPanel Orientation="Vertical">
                                                                    <Label Content="{Binding Name}"></Label>
                                                                    <StackPanel Orientation="Vertical">
                                                                        <TextBox Text="{Binding Value}" Width="270"/>
                                                                    </StackPanel>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </local:TemplateEntry.DataTemplate>
                                                    </local:TemplateEntry>
                                                    <local:TemplateEntry  >
                                                        <local:TemplateEntry.DataTemplate >
                                                            <DataTemplate  DataType="{x:Type configValues:ConfigurableBooleanValueEntry}" >
                                                                <StackPanel Orientation="Vertical">
                                                                    <Label Content="{Binding Name}"></Label>
                                                                    <StackPanel Orientation="Vertical">
                                                                        <CheckBox IsChecked="{Binding Value}" Width="270"/>
                                                                    </StackPanel>
                                                                </StackPanel>
                                                            </DataTemplate>
                                                        </local:TemplateEntry.DataTemplate>
                                                    </local:TemplateEntry>
                                                </local:GeneralTemplateSelector.Templates>
                                            </local:GeneralTemplateSelector>
                                        </ItemsControl.ItemTemplateSelector>
                                    </ItemsControl>
                                </Expander>
                            </Border>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </ScrollViewer>
        </Grid>
        <Border Grid.Column="1" Grid.Row="2" CornerRadius="5" BorderBrush="Silver"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="2" Margin="5">
            <Grid HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <ScrollViewer Grid.Row="0">
                    <ListView Name="StatisticsValues" SelectionChanged="StatisticsValues_SelectionChanged">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <Label Content="{Binding Name}"></Label>
                                    <ContentPresenter Content="{Binding Value}"></ContentPresenter>
                                </StackPanel>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </ScrollViewer>
            </Grid>
        </Border>
        <Border Grid.Column="2" Grid.Row="2" CornerRadius="5" MinWidth="400" BorderBrush="Silver" VerticalAlignment="Stretch" HorizontalAlignment="Center" BorderThickness="2" Margin="5">
            <ScrollViewer >
                <ItemsControl Name="ImagesResults">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical">
                                <Label Content="{Binding Id}"></Label>
                                <Image Stretch="None">
                                    <Image.Source>
                                        <Binding Path="ImageData">
                                            <Binding.Converter>
                                                <local:ImageToBitmapSourceConverter/>
                                            </Binding.Converter>
                                        </Binding>
                                    </Image.Source>
                                </Image>
                                <!--    <WindowsFormsHost HorizontalAlignment="Left"  VerticalAlignment="Top">
                                <emgu:ImageBox Image="{Binding ImageData}" Width="400" Height="300" />
                            </WindowsFormsHost>-->
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
        </Border>
        <Border Grid.ColumnSpan="2" Grid.Column="0" Grid.Row="3" CornerRadius="5"  BorderBrush="Silver" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" BorderThickness="2" Margin="5">

            <chart:Chart x:Name="m_chart" Bevel="False" AnimationEnabled="True" LightingEnabled="False" Theme="Theme1" ShadowEnabled="False" View3D="False">
                <chart:Chart.AxesX>
                    <chart:Axis AxisMaximum="30" AxisMinimum="0">
                        <chart:Axis.AxisLabels>
                            <chart:AxisLabels />
                        </chart:Axis.AxisLabels>
                    </chart:Axis>
                </chart:Chart.AxesX>
                <chart:Chart.Legends>
                    <chart:Legend Enabled="True" >

                    </chart:Legend>
                </chart:Chart.Legends>
            </chart:Chart>
        </Border>
        <GridSplitter ResizeDirection="Rows" Height="2" Grid.Row="2" Grid.ColumnSpan="3" Background="Silver"  HorizontalAlignment="Stretch" 
                    VerticalAlignment="Bottom"></GridSplitter>
        <local:ActivityRatingVisualizer x:Name="ratingVisualizer" Grid.Column="3" Grid.Row="2" Margin="5"></local:ActivityRatingVisualizer>
        <local:ActivityRatingVisulizerField x:Name="ratingVisualizerField" Grid.Column="2" Grid.Row="3" Margin="5" Grid.ColumnSpan="2" ></local:ActivityRatingVisulizerField>
    </Grid>
</Window>
